<!DOCTYPE HTML>
<html>
<head>
    {include file='common_header'}
    <style>
        #hearders{
            background:#5BC0DE;
        }
        #bodys{
            background:#efefef
        }
    </style>
</head>
<body>
<div class="page-container">
    <form action="{:Url('add')}" method="post" class="form form-horizontal" id="form-admin-role-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>角色名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" datatype="*" nullmag="请输入名称" errormsg="请输入名称 " name="title">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="content" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true" onKeyUp="$.Huitextarealength(this,100)"></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">权限编辑：</label>
            <div class="formControls col-xs-8 col-sm-9">
                {volist name="menulist" id="v"}
                <dl class="permission-list">
                    <dt id="hearders">
                        <label>
                            <input type="checkbox" value="{$v['id']}" name="menu[]" id="user-Character-0">
                            {$v['title']}
                        </label>
                    </dt>
                    <dd id="bodys">
                        <dl class="cl permission-list2">
                            {volist name="$v['child']" id="vv"}
                            <dt style="margin-right: 10px" >
                                <label class="">
                                    <input type="checkbox"   value="{$vv['id']}" name="menu[]" id="user-Character-0-0">
                                    {$vv['title']}</label>
                            </dt>
                            {/volist}
                        </dl>
                    </dd>
                </dl>
                {/volist}
            </div>
        </div>
        <div class="row cl" style="margin-top: 50px">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-5">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;确定&nbsp;&nbsp;">
                <!--<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>-->
            </div>
        </div>
    </form>
</div>
<!--_footer 作为公共模版分离出去-->
{include file='common_footer'}
<script type="text/javascript">
    $(function(){
        $(".permission-list dt input:checkbox").click(function(){
            $(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
        });
        $(".permission-list2 dd input:checkbox").click(function(){
            var l =$(this).parent().parent().find("input:checked").length;
            var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
            if($(this).prop("checked")){
                $(this).closest("dl").find("dt input:checkbox").prop("checked",true);
                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
            }
            else{
                if(l==0){
                    $(this).closest("dl").find("dt input:checkbox").prop("checked",false);
                }
                if(l2==0){
                    $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
                }
            }
        });
    });
</script>
</body>
</html>